package org.ymf.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.layuiframework.stereotype.util.ValidGroup;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.beans.BeanUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.layuiframework.stereotype.elasticsearch.ElasticsearchRecord;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

/**
 * <p>
 * 图表信息表
 * </p>
 *
 * @author Malphite
 * @since 2023-08-01
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="Chart对象", description="图表信息表")
public class Chart extends ElasticsearchRecord implements Serializable {

    private static final long serialVersionUID = 1L;

    @ExcelProperty(value = "id")
    @ApiModelProperty(value = "id")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @ExcelProperty(value = "分析目标")
    @ApiModelProperty(value = "分析目标")
    @NotBlank(message = "目标为空", groups = {ValidGroup.Insert.class })
    private String goal;

    @ExcelProperty(value = "图表名称")
    @ApiModelProperty(value = "图表名称")
    @NotBlank(message = "名称为空", groups = {ValidGroup.Insert.class })
    @Size(max = 100, message = "名称过长", groups = {ValidGroup.Insert.class })
    private String name;

    @ExcelProperty(value = "图表数据")
    @ApiModelProperty(value = "图表数据")
    @TableField("chartData")
    private String chartdata;

    @ExcelProperty(value = "图表类型")
    @ApiModelProperty(value = "图表类型")
    @NotBlank(message = "图表类型为空", groups = {ValidGroup.Insert.class })
    @TableField("chartType")
    private String charttype;

    @ExcelProperty(value = "生成的图表数据")
    @ApiModelProperty(value = "生成的图表数据")
    @TableField("genChart")
    private String genchart;

    @ExcelProperty(value = "生成的分析结论")
    @ApiModelProperty(value = "生成的分析结论")
    @TableField("genResult")
    private String genresult;

    @ExcelProperty(value = "状态")
    @ApiModelProperty(value = "状态")
    private String status;

    @ExcelProperty(value = "执行信息")
    @ApiModelProperty(value = "执行信息")
    @TableField("execMessage")
    private String execmessage;

    @ExcelProperty(value = "创建用户 id")
    @ApiModelProperty(value = "创建用户 id")
    @TableField("userId")
    private Long userid;

    @ExcelProperty(value = "创建时间")
    @ApiModelProperty(value = "创建时间")
    @TableField(value = "createTime", fill = FieldFill.INSERT)
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date createtime;

    @ExcelProperty(value = "更新时间")
    @ApiModelProperty(value = "更新时间")
    @TableField(value = "updateTime", fill = FieldFill.INSERT_UPDATE)
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date updatetime;

    @ExcelProperty(value = "是否删除")
    @ApiModelProperty(value = "是否删除")
    @TableField("isDelete")
    @TableLogic
    private Integer isdelete;


    /**
     * 将{@linkplain Chart 数据库映射对象} 转化为 {@linkplain ChartEs Elasticsearch映射对象}
     */
    public ChartEs transform(){
        ChartEs entity = new ChartEs();
        BeanUtils.copyProperties(this, entity);
        return entity;
    }
}
